Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run gRPC service independently #158

Merged
merged 1 commit into from
Jan 30, 2025
Merged

Run gRPC service independently #158

merged 1 commit into from
Jan 30, 2025

Conversation

elviscapiaq
Copy link
Collaborator

No description provided.

@elviscapiaq elviscapiaq marked this pull request as draft January 9, 2025 04:38
@elviscapiaq
Copy link
Collaborator Author

I put this PR as a draft to validate the implementation. Please let me know if I am moving in the right track.
Also, I did the testing with several apps, including the Unity app with two-instance creation. For all tests, the gRPC service runs successfully.

@elviscapiaq elviscapiaq force-pushed the main branch 2 times, most recently from c3ac50b to cf7a861 Compare January 9, 2025 04:50
layer/openxr_layer.cc Outdated Show resolved Hide resolved
@RenfengLiu
Copy link
Collaborator

you'll also need to update the Vulkan side as well, otherwise the server will be started twice for Vulkan application.
please also test with Vulkan application, OpenXR application, and also the shared Unity application that we know has problem.

@elviscapiaq elviscapiaq force-pushed the main branch 2 times, most recently from b32a615 to 952b9b9 Compare January 10, 2025 02:05
@elviscapiaq
Copy link
Collaborator Author

elviscapiaq commented Jan 10, 2025

you'll also need to update the Vulkan side as well, otherwise the server will be started twice for Vulkan application. please also test with Vulkan application, OpenXR application, and also the shared Unity application that we know has problem.

I added also a global object to initialize the server for an Vulkan app, however, it is not working. It seems the server is closed. When I move the server initialization to DiveInterceptCreateInstance at vk_layer_base.cc it works.

layer/openxr_layer.cc Outdated Show resolved Hide resolved
@RenfengLiu
Copy link
Collaborator

initialize

Did you find out why? In theory it should, as it's just move the place of initialization.

layer/layer_common.h Outdated Show resolved Hide resolved
@elviscapiaq elviscapiaq marked this pull request as ready for review January 27, 2025 22:14
@elviscapiaq
Copy link
Collaborator Author

I have updated this PR which now works for all tests I have.
The problem was that the loading/unloading behavior of the Vulkan/OpenXR Dive layer library varies significantly across Android applications.For example for Vulkan apps it loads - unloads - reloads the library during execution. For an Unity-based OpenXR
app that creates two instances, the behavior is the same.

To addres this now the gRPC Server starts when the library loads for the first time. Then, a function prevents the library from being unloaded. This keeps both the library and server loaded exactly once, even if apps try to reload or close them. In this way, the Server lives for the entire lifecycle of the app.

The loading/unloading behavior of the Vulkan/OpenXR Dive layer library varies significantly across Android applications.
For example for Vulkan apps it loads - unloads - reloads the library during execution. For an Unity-based OpenXR
app that creates two instances, the behavior is the same.

The gRPC Server starts when the library loads for the first time. Then, a function prevents the library from being unloaded.
This keeps both the library and server loaded exactly once, even if apps try to reload or close them.
In this way, the Server lives for the entire lifecycle of the app.
@elviscapiaq
Copy link
Collaborator Author

I updated the PR to support Windows as well.

@elviscapiaq
Copy link
Collaborator Author

I tested on Windows, and everything work fine.

@elviscapiaq elviscapiaq merged commit b4f8b82 into google:main Jan 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants